package com.zhoushihao.class0812;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Window {
    public int x1;
    public int y1;
    public int x2;
    public int y2;
    public int Num;

    public Window(int x1, int y1, int x2, int y2, int Num) {
        this.x1 = x1;
        this.y1 = y1;
        this.x2 = x2;
        this.y2 = y2;
        this.Num = Num;
    }

    public boolean isMouseInWindow(int x ,int y){
        return x>=this.x1&&x<=this.x2&&y>=this.y1 && y<=this.y2;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        List<Window> windows = new ArrayList<Window>();
        for (int i = 0; i < N; i++) {
            int x1 = sc.nextInt();
            int y1 = sc.nextInt();
            int x2 = sc.nextInt();
            int y2 = sc.nextInt();
            windows.add(new Window(x1, y1, x2, y2,i+1));
        }
        for (int i = 0; i < M; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            int flag = 0;
            for (int j = windows.size()-1; j >= 0; j--) {
                if(windows.get(j).isMouseInWindow(x, y)){
                    System.out.println(windows.get(j).Num);
                    flag = 1;
                    windows.add(windows.get(j));
                    windows.remove(j);
                    break;
                }
            }
            if(flag==0){
                System.out.println("IGNORED");
            }
        }
    }
}
